package star.动态规划.最长不重复子串;

public class LengthOfLongestSubstring {
    public int lengthOfLongestSubstring(String s) {
        int max = 0;
        int j = 0;
        for (int i = 0; i < s.length(); i++) {
            char head = s.charAt(i);
            for (int k = j; k < i; k++) {
                if (s.charAt(k) == head) {
                    j = k + 1;
                    break;
                }
            }
            max = Math.max(i - j + 1, max);
        }
        return max;
    }
}
